package com.zeldu.myclass.service.impl;

import com.zeldu.myclass.mapper.MyClassMapper;
import com.zeldu.myclass.pojo.MyClass;
import com.zeldu.myclass.pojo.Student;
import com.zeldu.myclass.service.MyClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyClassServiceImpl implements MyClassService {
    @Autowired(required = false)
    private MyClassMapper myClassMapper;

    @Override
    public List<MyClass> getClasses(Long id) {
        return myClassMapper.getClasses(id);
    }

    @Override
    public int addClass(MyClass myClass) {
        return myClassMapper.insert(myClass);
    }

    @Override
    public int deleteClass(Long id) {
        myClassMapper.delClassInStudent(id);
        return myClassMapper.deleteById(id);
    }

    @Override
    public int removeStudent(Long id) {
        return myClassMapper.removeStudent(id);
    }

    @Override
    public List<Student> getStudents(Long id) {
        return myClassMapper.getStudents(id);
    }
}
